'\" te
.\" Copyright (c) 2006, Sun Microsystems, Inc.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH DDI_MAP_REGS 9F "March 6, 2023"
.SH NAME
ddi_map_regs, ddi_unmap_regs \- map or unmap registers
.SH SYNOPSIS
.nf
#include <sys/conf.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>



\fBint\fR \fBddi_map_regs\fR(\fBdev_info_t *\fR\fIdip\fR, \fBuint_t\fR \fIrnumber\fR, \fBcaddr_t *\fR\fIkaddrp\fR,
     \fBoff_t\fR \fIoffset\fR, \fBoff_t\fR \fIlen\fR);
.fi

.LP
.nf
\fBvoid\fR \fBddi_unmap_regs\fR(\fBdev_info_t *\fR\fIdip\fR, \fBuint_t\fR \fIrnumber\fR, \fBcaddr_t *\fR\fIkaddrp\fR,
     \fBoff_t\fR \fIoffset\fR, \fBoff_t\fR \fIlen\fR);
.fi

.SH INTERFACE LEVEL
These interfaces are obsolete. Use \fBddi_regs_map_setup\fR(9F) instead of
\fBddi_map_regs()\fR. Use \fBddi_regs_map_free\fR(9F) instead of
\fBddi_unmap_regs()\fR.
.SH PARAMETERS
.SS "\fBddi_map_regs()\fR"
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 11n
Pointer to the device's dev_info structure.
.RE

.sp
.ne 2
.na
\fB\fIrnumber\fR\fR
.ad
.RS 11n
Register set number.
.RE

.sp
.ne 2
.na
\fB\fIkaddrp\fR\fR
.ad
.RS 11n
Pointer to the base kernel address of the mapped region (set on return).
.RE

.sp
.ne 2
.na
\fB\fIoffset\fR\fR
.ad
.RS 11n
Offset into register space.
.RE

.sp
.ne 2
.na
\fB\fIlen\fR\fR
.ad
.RS 11n
Length to be mapped.
.RE

.SS "\fBddi_unmap_regs()\fR"
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 11n
Pointer to the device's dev_info structure.
.RE

.sp
.ne 2
.na
\fB\fIrnumber\fR\fR
.ad
.RS 11n
Register set number.
.RE

.sp
.ne 2
.na
\fB\fIkaddrp\fR\fR
.ad
.RS 11n
Pointer to the base kernel address of the region to be unmapped.
.RE

.sp
.ne 2
.na
\fB\fIoffset\fR\fR
.ad
.RS 11n
Offset into register space.
.RE

.sp
.ne 2
.na
\fB\fIlen\fR\fR
.ad
.RS 11n
Length to be unmapped.
.RE

.SH DESCRIPTION
The \fBddi_map_regs()\fR function maps in the register set given by
\fIrnumber\fR. The register number determines which register set will be mapped
if more than one exists. The base kernel virtual address of the mapped register
set is returned in \fIkaddrp\fR. \fIoffset\fR specifies an offset into the
register space to start from and \fIlen\fR indicates the size of the area to be
mapped. If \fIlen\fR is non-zero, it overrides the length given in the register
set description. If \fIlen\fR and
\fIoffset\fR are 0, the entire space is mapped.
.sp
.LP
The \fBddi_unmap_regs()\fR function undoes mappings set up by
\fBddi_map_regs()\fR. This is provided for drivers preparing to detach
themselves from the system, allowing them to release allocated mappings.
Mappings must be released in the same way they were mapped (a call to
\fBddi_unmap_regs()\fR must correspond to a previous call to
\fBddi_map_regs()\fR). Releasing portions of previous mappings is not allowed.
\fIrnumber\fR determines which register set will be unmapped if more than one
exists. The \fIkaddrp\fR, \fIoffset\fR and \fIlen\fR specify the area to be
unmapped. \fIkaddrp\fR is a pointer to the address returned from
\fBddi_map_regs()\fR; \fIoffset\fR and \fIlen\fR should match what
\fBddi_map_regs()\fR was called with.
.SH RETURN VALUES
The \fBddi_map_regs()\fR function returns:
.sp
.ne 2
.na
\fB\fBDDI_SUCCESS\fR\fR
.ad
.RS 15n
on success.
.RE

.SH CONTEXT
These functions can be called from user, interrupt, or kernel context.
.SH ATTRIBUTES
See \fBattributes\fR(7) for a description of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Obsolete
.TE

.SH SEE ALSO
.BR attributes (7),
.BR ddi_regs_map_free (9F),
.BR ddi_regs_map_setup (9F)
.sp
.LP
\fIWriting Device Drivers\fR
